/*
 *  Netzpult - Your desk on the web
 *  Copyright (C) 2011  Ulrich Hilger, http://uhilger.de
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see http://www.gnu.org/licenses/
 */

package de.uhilger.netzpult.shared;

import java.io.Serializable;

import de.uhilger.baselink.DBColumn;
import de.uhilger.baselink.DBPrimaryKey;
import de.uhilger.baselink.DBTable;

/**
 * UserShare
 * 
 * @author Copyright (c) Ulrich Hilger, http://uhilger.de
 * @author Published under the terms and conditions of
 * the <a href="http://www.gnu.org/licenses/" target="_blank">GNU General Public License</a>
 */
@DBTable(name = "webfiles.document_shares")
@DBPrimaryKey({"dc_id","us_id"})
public class UserShare implements Serializable {
	
	private static final long serialVersionUID = -6190118189919015010L;
	public static final int NONE = 0;
	public static final int READ = 1;
	public static final int READ_WRITE = 2;

	private int docId;
	private String userId;
	private int rights;
	
	public UserShare() {
		super();
	}

	@DBColumn(name = "dc_id")
	public int getDocId() {
		return docId;
	}

	public void setDocId(int docId) {
		this.docId = docId;
	}

	@DBColumn(name = "us_id")
	public String getUserId() {
		return userId;
	}

	public void setUserId(String userId) {
		this.userId = userId;
	}

	@DBColumn(name = "ds_rights")
	public int getRights() {
		return rights;
	}

	public void setRights(int rights) {
		this.rights = rights;
	}

	@Override
	public boolean equals(Object obj) {
		boolean isEqual = false;
		if(obj != null && obj instanceof UserShare) {
			UserShare other = (UserShare) obj;
			isEqual = ((this.docId == other.docId) && this.userId.equals(other.getUserId()));
		}
		return isEqual;
	}
	
	
	
}
